<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统参数</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">

    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
</head>
<body>           
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>系统参数</legend>
</fieldset>

<form class="layui-form layui-form-pane" action="" lay-filter="example" style="padding: 20px">
    <input type="hidden" name="id" value="{$info.id}" lay-verify="id">

    <div class="layui-form-item">
        <label class="layui-form-label">APPID</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="appid" value="{$info.appid}" lay-verify="appid" autocomplete="off" placeholder="请输入小程序APPID" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">APPSecret</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="appsecret" value="{$info.appsecret}" lay-verify="appsecret" autocomplete="off" placeholder="请输入小程序appsecret" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商户号</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="mch_id" value="{$info.mch_id}" lay-verify="mch_id" autocomplete="off" placeholder="请输入商户号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">支付密钥</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="wx_key" value="{$info.wx_key}" lay-verify="wx_key" autocomplete="off" placeholder="请输入微信支付密钥" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">推荐奖(一)</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="number" name="push_award_fst" value="{$info.push_award_fst}" lay-verify="push_award_fst" autocomplete="off" placeholder="请输入推荐奖(一级)" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <span style="color: red">*</span> 平级（会员等级）之间的固定奖励
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">推荐奖(二)</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="number" name="push_award_sec" value="{$info.push_award_sec}" lay-verify="push_award_sec" autocomplete="off" placeholder="请输入推荐奖(二级)" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <span style="color: red">*</span> 平级（会员等级）之间的固定奖励
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form', 'layedit'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit;

        // 监听提交
        form.on('submit(submit)', function(data){
            if(!data.field.is_push){
                data.field.is_push = 0;
            }

            console.log(data.field)
            $.post('{:url("System/system_data")}', data.field, function(res){
                if(res.code == 0){
                    layer.msg(res.msg, {icon: 1});
                    setTimeout(() => {
                        window.location.href = "{:url('System/system_list')}";
                    }, 1000);
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            })

            return false;
        });
    });
</script>
</body>
</html>